package com.eta.common.exception;

import com.eta.common.constant.ResultCodeEnum;
import lombok.Getter;

/**
 * @author 星河一叶Ck
 * @date 2025/9/7
 * @description 自定义业务异常：仅用于业务逻辑层面的异常（如“账号已存在”“密码错误”）
 */

@Getter
public class BusinessException extends RuntimeException{
    private final Integer errorCode;

    // 构造方法1：传入错误码 + 错误消息
    public BusinessException (Integer errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    // 构造方法2：直接传入枚举
    public BusinessException (ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMsg());
        this.errorCode = resultCodeEnum.getCode();
    }
}
